<html>
<head>
<title>getImageData() on redirected canvas img (Adapted from LayoutTests)</title>
<script type="text/javascript" src="/shared/scripts/testcase.js"></script>
<script type="text/javascript">

function draw() {
	var tc = new TestCase();
	tc.input = 'getImageData(); on redirected canvas img';
	tc.description = 'This tests that drawing an image that redirects to a remote image to a canvas taints the canvas (Adapted from LayoutTests)';
	tc.expected_result = "canvas tainted or unsupported.";
	tc.test_passed = 'true';
	
	var canvas = null;
	var ctx = null;
	
	try {
		canvas = document.getElementById("canvas");
		ctx = canvas.getContext("2d");
		ctx.drawImage(document.getElementById("img"), 0, 0);
	} catch(e) {
		tc.result = 'unsupported';
		tc.saveTest();
		return;
	}
		
		
    try {
        var data = ctx.getImageData(20, 20, 290, 75);
        tc.output += 'getImageData succeeded. Canvas not tainted: ' + data + '\n';
		tc.result = 'canvas not tainted';
		tc.test_passed = 'false';
    } catch (e) {
        tc.output += 'getImageData failed. Canvas tainted: ' + e;
		tc.result = 'canvas tainted';
    }
	tc.saveTest();
}
</script>
</head>
<body>
<canvas id="canvas" width="330" height="115"></canvas>
<img id="img" onload="draw()" src="/redirect?loc=http://victim.com/shared/resources/layouttests/abe.png">
</body>
</html>